package com.wjc.jcweather.ui.place

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.wjc.jcweather.logic.Repository
import com.wjc.jcweather.logic.model.Place

/**
 * ClassName: com.wjc.jcweather.ui.place
 * Description:
 * JcChen on 2020.10.01.5:31 PM
 */
class PlaceViewModel : ViewModel() {
    private val searchLiveData = MutableLiveData<String>()
    val placeList = ArrayList<Place>()
    val placeLiveData =
        Transformations.switchMap(searchLiveData) { query -> Repository.searchPlaces(query) }

    fun searchPlaces(query: String) {
        searchLiveData.value = query
    }
}